<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>2.特殊写法</title>
    <!-- 引入Vue -->
    <script type="text/javascript" src="../../vue.js"></script>
  </head>
  <body>
    <!-- 准备好一个容器-->
    <div id="demo">
      <h2>姓名：{{person.name}}</h2>
      <h2>年龄：{{person.age}}</h2>
      <button @click="person.name = '马冬梅'">修改名字</button>
      <button @click="person.age += 1">修改年龄</button>
    </div>

    <script type="text/javascript">
      new Vue({
        el:'#demo',
        data:{
          person:{
            name:'马志强',
            age:18
          },
        },
        watch:{
          'person.age':{
            deep:true,
            handler(value){
              console.log('person变化了',value)
            }
          }
        }
      })
    </script>
  </body>
</html>